package com.kim.smartring.net.entity;

import org.json.JSONObject;

import android.content.Context;
import android.util.Log;

import com.kim.smartring.db.model.User;
import com.kim.smartring.net.IReceiverListener;

public class RegisterEntity extends BaseEntity {

	private static final String TAG = "RegisterEntity";

	String account;
	String password;
	int gender;
	long birthday;
	int height;
	float weight;
	String address;
	String deviceId;

	public RegisterEntity(Context context, IReceiverListener receiverListener) {
		super(context, receiverListener);
	}

	public RegisterEntity(Context context, User user,
			IReceiverListener receiverListener) {
		super(context, receiverListener);

		this.account = user.getAccount(); // account;
		this.password = user.getPassword(); // password;
		this.gender = user.getGender(); // gender;
		this.birthday = user.getAge(); // birthday;
		this.height = user.getHeight(); // height;
		this.weight = user.getWeight();// weight;
		this.address = user.getUserAddress(); // address;
		this.deviceId = user.getDeviceAddress(); // deviceId;

	}

	@Override
	protected void init() {
		this.url = URLConstant.URL_REGISTER;
	}

	@Override
	public String getSendData() {
		return generateSendData();
	}

	private String generateSendData() {
		JSONObject jsonObject = new JSONObject();
		String sendData = null;
		try {
			jsonObject.put("account", account);
			jsonObject.put("password", password);
			jsonObject.put("gender", gender);
			jsonObject.put("birthday", birthday);
			jsonObject.put("height", height);
			jsonObject.put("weight", weight);
			jsonObject.put("address", address);
			jsonObject.put("deviceId", deviceId);
			sendData = jsonObject.toString();
			Log.d(TAG, String.format("register send data:%s", sendData));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			jsonObject = null;
		}
		return sendData;
	}

	/*
	 * { 　　“account”:”kim”, 　　“password”:”1234567”, 　　“gender”:1,
	 * 　　“birthday”:124356375985896, 　　“height”:168, 　　“weight”:76,
	 * 　　“address”:”深圳”, 　　“deviceId”:”设备号” }
	 */

}
